package com.yangfan.cloudalibaba.controller;

import com.yangfan.cloudalibaba.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RequestMapping(value = "/order")
@RestController
@Slf4j

public class NacosOrderController {




    @Autowired
    private PaymentService paymentService;

    @GetMapping(value = "/consumer/payment/getPayment/{id}")
    public String getPayment(@PathVariable(value = "id") Long id) {
        return paymentService.getPayment(id);
    }



    //  获取 Nacos 配置中心 动态 配置的 内容信息

    @GetMapping(value = "/consumer/payment/getInfo")
    public String getInfo() {
        return paymentService.getInfo();
    }




    // ========================  Sentinel  ==========================================


    /**
     * Sentinel 降级 测试
     * @param name
     * @return
     */
    @GetMapping(value = "/consumer/payment/sentinel/hello/{name}")
    public String apiHello(@PathVariable(value = "name") String name) {
        return paymentService.apiHello(name);
    }


    /**
     * 热点规则  限流  接口
     * @param p1
     * @param p2
     * @return
     */
    @GetMapping(value = "/consumer/payment/sentinel/hotKey")
    public String testHotKey(@RequestParam(value = "p1",required = false) String p1 , @RequestParam(value = "p2",required = false) String p2) {
        return paymentService.testHotKey(p1,p2);
    }




}
